/*
 * @Descripttion: 
 * @version: 
 * @Author: TT
 * @Date: 2022-06-23 11:36:16
 * @LastEditors: TT
 * @LastEditTime: 2022-07-11 16:12:59
 */

import 'package:flutter/material.dart';
import 'package:hzy_template/config/dataconfig/language_info_config.dart';
import '../../../components/common_index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hzy_normal_widget/hzy_normal_widget.dart';
import '../../../config/config_index.dart';
import '../../../config/models/normmal_title_item_model.dart';
import '../controllers/my_launch_c.dart';

class MyLaunchV extends CommonGetXWidget<MyLaunchC> {
  MyLaunchV({Key? key}) : super(key: key);
  @override
  MyLaunchC get controller => Get.put(MyLaunchC());

  @override
  String? get title => LauchNormalMsg.launch;
  @override
  Color? get backgroundColor => HzyColorConfig().backgroudgrey;
  @override
  Color? get navbackcolor => HzyColorConfig().backgroudgrey;

  @override
  Widget createBody(BuildContext context) {
    return ListView.builder(
      itemBuilder: createItemBuilder,
      itemCount: controller.listleng.value,
    );
  }

  /// 创建导航栏 右边按钮集合
  @override
  List<Widget>? createAppBaractions() {
    return [
      Obx(
        () => InkWell(
          onTap: () {
            if (controller.iscantap.value) {
              controller.changelaunch();
            }
          },
          child: Container(
            padding: EdgeInsets.only(
              left: 10.w,
              right: 10.w,
              top: 2.w,
              bottom: 2.w,
            ),
            margin: EdgeInsets.only(top: 10.w, bottom: 10.w, right: 10.w),
            alignment: Alignment.center,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(
                Radius.circular(4.r),
              ),
              color: controller.surebackColor.value,
            ),
            child: Text(
              LauchNormalMsg.done,
              style: TextStyleMacor.configtextstyle(
                14.sp,
                controller.suretitleColor.value,
                font: FontWeight.normal,
              ),
            ),
          ),
        ),
      )
    ];
  }

  Widget createItemBuilder(BuildContext context, int index) {
    NormalTitleItemModel model = controller.list[index];
    return CreateNormalItemWidget(
      title: model.leftmsg,
      padding: EdgeInsets.only(left: 20.w, right: 20.w),
      isshowline: model.showline,
      istap: model.istap,
      index: model.index,
      rightwidget: Obx(
        () => controller.selectIndex.value == index
            ? Icon(
                Icons.check,
                size: 16.w,
                color: HzyColorConfig().colthemes,
              )
            : Container(),
      ),
      ontap: (index) {
        controller.tapItem(model: model);
      },
    );
  }
}
